package alisdk

import (
	"chess_platform/internal/stringutils"
	"fmt"
	"io"
	"strings"
	"time"
)

func UploadFileToOss(reader io.Reader, filename, savePath string, id int64) (ossPath string, err error) {
	ext := stringutils.SubString(stringutils.Unicode(filename),
		strings.LastIndex(stringutils.Unicode(filename), "."), 5)
	filename = fmt.Sprintf("%d%d", time.Now().UnixNano(), id) + ext

	ossPath = GetImagePath(savePath, filename)
	err = PutFileStreamToOss(ossPath, reader)
	return ossPath, err

}
